package com.msmall.community.team.dao.hiberante;

import java.util.List;

import com.msmall.base.dao.hibernate.BaseDaoHibernate;
import com.msmall.community.team.dao.TeamPropertyDao;
import com.msmall.community.team.model.TeamProperty;

public class TeamPropertyDaoHiberante extends BaseDaoHibernate<TeamProperty,Long> implements TeamPropertyDao{
	
	public TeamPropertyDaoHiberante(){
		super(TeamProperty.class);
	}
	
	public TeamProperty load(Long teamid, String key) throws Exception{
		try{
			String queryString = "from TeamProperty o where o.team.teamid=? and propertyKey=?";
			List list = getHibernateTemplate().find(queryString, new Object[]{teamid, key});
			if(list != null && list.size() ==1)
				return (TeamProperty) list.get(0);
			return null;
		}catch(Exception e){
			throw e;
		}
	}
	
	/**
	 * 获得一个组的所有属性
	 */
	public List<TeamProperty> loadAllProperties(Long teamid) throws Exception{
		try{
			String queryString = "from TeamProperty o where o.team.teamid=?";
			List list = getHibernateTemplate().find(queryString, new Object[]{teamid});
			return list;
		}catch(Exception e){
			throw e;
		}
	}
}
